<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );

class ModelBPNewsNews extends JModel 
{
	var $_news = null;
	var $_id = null;
	
	function __construct()
	{
		parent::__construct();
		$id = JRequest::getVar( 'id', 0 );
		$this->_id = $id;
	}
	
	function getNews()
	{
		if( !$this->_news )
		{
			$query = "SELECT * FROM #__bpnews WHERE id = '" . $this->_id . "'";
			$this->_db->setQuery( $query );
			$this->_news = $this->_db->loadObject();
			if( !$this->_news->published )
			{
				JError::raiseError( 404, "Invalid ID provided" );
			}
		}
		return $this->_news;
	}
}
?>